package ywpt.web.action.config;

import ywpt.core.web.BaseAction;
import ywpt.model.WarnSet;
import ywpt.service.config.WarnSetService;

import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class WarnSetAction extends BaseAction implements
ModelDriven<WarnSet>, Preparable{

	/**
	 * 提醒设置Action
	 */
	private static final long serialVersionUID = -7209436946509318076L;
	private Long id;
	private WarnSet warnSet;
	private WarnSetService warnSetService;
	
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public WarnSet getWarnSet() {
		return warnSet;
	}

	public void setWarnSet(WarnSet warnSet) {
		this.warnSet = warnSet;
	}

	public WarnSetService getWarnSetService() {
		return warnSetService;
	}

	public void setWarnSetService(WarnSetService warnSetService) {
		this.warnSetService = warnSetService;
	}

	@Override
	public WarnSet getModel() {
		return this.warnSet;
	}

	@Override
	public void prepare() throws Exception {
		if(id != null){
			this.warnSet = this.warnSetService.getWarnSetById(id);
		}else{
			this.warnSet = new WarnSet();
		}
	}
	public String edit(){
		this.warnSet = this.warnSetService.getWarnSetById(id);
		return SUCCESS;
	}
	
	public String save(){
		if(id == null){
			this.warnSetService.SaveWarnSet(warnSet);
			this.addActionMessage("信息保存成功！");
		}else{
			this.warnSetService.UpdateWarnSet(warnSet);
			this.addActionMessage("信息更新成功！");
		}
		return SUCCESS;
	}
	
}
